<template>
  <div>
    <audio v-if="viewType === 'audio'" controls controlslist="nodownload" ref="viewAudio">
      <source :src="viewFileUrl" type="audio/mp3" />
      <source :src="viewFileUrl" type="audio/ogg" />
      <source :src="viewFileUrl" type="audio/mpeg" />
      <embed width="100%" :src="viewFileUrl" />
    </audio>
    <!-- disablePictureInPicture取消画中画 -->
    <video v-else-if="viewType === 'video'" controls controlslist="nodownload" disablePictureInPicture>
      <source :src="viewFileUrl" type="video/mp4" />
      <source :src="viewFileUrl" type="video/ogg" />
      <source :src="viewFileUrl" type="video/webm" />
      <object :data="viewFileUrl" width="100%">
        <embed :src="viewFileUrl" width="100%" />
      </object>
    </video>
  </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
  name: 'MediaPreview',
  props: {
    viewFileUrl: {
      type: String,
      default: ''
    },
    viewType: {
      type: String,
      default: ''
    }
  }
})
</script>
<style lang="stylus" scoped>
video
  width 100%
</style>
